package servlets;

import interfaceDAO.SessionFormationJDBCDAO;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import classes.SessionFormation;

/**
 * Servlet implementation class AjoutClientASession
 */
public class AjoutClientASessionServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AjoutClientASessionServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter out = response.getWriter();
		response.setContentType("text.html");
		ArrayList<SessionFormation>sessionsFormationList = new ArrayList<SessionFormation>();
		SessionFormationJDBCDAO dao = new SessionFormationJDBCDAO();
		sessionsFormationList = dao.getSessionFormationsList();
		
		out.println("<FORM method=post action=\"/ProjetOrganismeFormation/?page=/logged/ajoutClientASession\">");
		out.println("<TABLE BORDER=0> <TR> <TD> "+ "dgdg" +"</TD> </TR>");
		out.println("<TR> <TD> "+ "dgdg" +"</TD> </TR>");
		out.println("<TABLE BORDER=0> <TR> <TD> Session </TD> </TR>");
		out.println("<TD> <SELECT name=\"session\">");
		
		for(SessionFormation next : sessionsFormationList){
			out.println("<option value="+ next.getId()+"><"+next.getFormationId()+ "du "+next.getDateDebut()+"au "+next.getDateFin()+"</option>");		
		}
		
		out.println("</SELECT> </TD> </TR>");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
